<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
  <div id="app">
     <button @click="marry">marry</button>
  </div>
</body>
<script src="../js/vue.js"></script>
<script>
    Vue.config.productionTip = false;
    var vm = new Vue({
      el:"#app",
      data:{msg:"message from data"},
      methods:{
        marry(){
          //触发vue的自定义事件
          setInterval(()=>{
              this.$emit("marry","早生贵子");
              this.$emit("test");
          },1000)
        }
      }
    })

    //注册vue的自定义事件!
    let zdy = (msg)=>{console.log("damu ❤ zdy",msg)}
    let dlrb = (msg)=>{console.log("damu ❤ 迪丽热巴",msg)}
    let glnz = (msg)=>{console.log("damu ❤ 古力娜扎",msg)}
    vm.$on("marry",zdy)
    vm.$on("marry",dlrb)
    vm.$on("marry",glnz)
    vm.$on("test",()=>{console.log("test")})

    setTimeout(()=>{
     // vm.$off() //移除所有的事件监听
     // vm.$off("test") //移除指定事件监听
     vm.$off("marry",dlrb) //移除指定事件监听
     vm.$off("marry",glnz) //移除指定事件监听
    },3000)
</script>
</html>